<!-- 繁殖管理 -->
<template>
	<view class="Mating">
		<view class="Mating-top">
			<view class="Mating-top-btn" :class="{active: box === 0}" @click="box=0">发情</view>
			<view class="Mating-top-btn" :class="{active: box === 1}" @click="box=1">节育</view>
		</view>
		<view v-if="box===0">
			<view class="item" v-for="(item,index) in Estrustable" :key="index">
				<view class="item-heat">
					<view class="item-left">
						<image src="@/static/imgs/cow.png" style="width: 70rpx;height: 70rpx;"></image>
						<view class="item-naber">
							<view>牲畜编号</view>
							<view>IMEI:{{item.F_IMEI}}</view>
						</view>
					</view>
					<view class="item-right">
						<i class="iconfont icon-xiangyoujiantou"></i>
					</view>
				</view>
				<view class="item-data">
					<view>预测发情时间：{{formatTime(item.F_EsTimateTime)}}</view>
					<view>实际发情时间：{{formatTime(item.F_SjTimateTime)}}</view>
				</view>
				<view class="item-footer">
					<view>操作员：{{item.F_Opert}}</view>
					<view>{{formatTime(item.F_CreateTime)}}</view>
				</view>
			</view>
			<navigator url="/pages/management/child/mating/AddHeat">
					<button class="btn">新增</button>
			</navigator>

		</view>
		<view v-if="box===1">
			<view class="item" v-for="(item,index) in Birthcontroltable" :key="index">
				<view class="item-heat">
					<view class="item-left">
						<image src="@/static/imgs/cow.png" style="width: 70rpx;height: 70rpx;"></image>
						<view class="item-naber">
							<view>牲畜编号</view>
							<view>IMEI:{{item.F_IMEI}}</view>
						</view>
					</view>
					<view class="item-right">
						<i class="iconfont icon-xiangyoujiantou"></i>
					</view>
				</view>
				<view class="item-data">
					<view>节育时间：{{formatTime(item.F_SjTimateTime)}}</view>
				</view>
				<view class="item-footer">
					<view>操作员：{{item.F_Opert}}</view>
					<view>{{formatTime(item.F_CreateTime)}}</view>
				</view>
			</view>
			<navigator url="/pages/management/child/mating/AddControl">
					<button class="btn">新增</button>
			</navigator>

		</view>
	</view>
</template>

<script setup>
	import {
		ref,onMounted
	} from 'vue'
	import {getbreedingList} from '@/utils/api/Management.js' 
	import dayjs from 'dayjs'
	const box = ref(0)
	const Estrustable=ref(null)
	const Birthcontroltable=ref(null)
	
	const list = async ()=>{
		let res = await getbreedingList()
		Estrustable.value=res.data.breedingList;
		Birthcontroltable.value=res.data.neverbreedList;
	}
	
	onMounted(()=>{
		list()
	})
	
	//日期转换函数
	const formatTime = (time) => {
	    return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
	}
</script>

<style scoped>
	@import '@/static/iconfont/iconfont.css';

	.Mating {
		width: 100%;
		min-height: 100vh; 
		background-color: #F3F5F8;
	}

	.Mating-top {
		width: 100%;
		height: 90rpx;
		display: flex;
		align-items: center;
	}

	.Mating-top-btn {
		flex: 1;
		text-align: center;
		padding: 10rpx;
		cursor: pointer;
		color: #666;
		/* 文字默认颜色 */
		border-bottom: 4rpx solid transparent;
		/* 初始下划线透明 */
	}

	.Mating-top-btn.active {
		color: #4CD964;
		/* 激活时文字绿色 */
		border-bottom-color: #4CD964;
		/* 激活时下划线绿色 */
	}

	.item {
		width: 90%;
		margin: 20rpx auto;
		height: 340rpx;
		background-color: #fff;
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		position: relative;
	}

	.item-heat {
		height: 120rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.item-left {
		display: flex;
		align-items: center;
		margin-left: 40rpx;
	}

	.item-right {
		margin-right: 40rpx;
	}

	.item-naber {
		margin-left: 20rpx;
	}

	.item-data {
		width: 100%;
		height: 100rpx;
		margin-left: 40rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
	}

	.item-footer {
		height: 70rpx;
		width: 90%;
		display: flex;
		justify-content: space-between;
		line-height: 70rpx;
		border-top: 1rpx solid #ccc;
		position: absolute;
		bottom: 0;
		left: 40rpx;
	}
	
	.btn {
		width: 100%;
		height: 90rpx;
		background-color: #0BCB75;
		position: fixed;
		/* 添加固定定位 */
		bottom: 0;
		/* 固定在屏幕底部 */
		left: 0;
		/* 水平方向居左对齐，如果要水平居中可通过其他方式调整 */
		z-index: 999;
		/* 确保按钮在其他元素之上显示，避免被遮挡 */
	}
</style>